/*
 * JHeuristics - The Java Meta-Heuritics Library
 * Copyright (C) 2004-2005, Universidade Federal de Campina Grande. All rights reserved.
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
package org.jheuristics.ga.operators.selectors;

import java.io.Serializable;

import org.jheuristics.ga.operators.selectors.roulettes.SUSRoulette;
import org.jheuristics.ga.scalers.FitnessScaler;
import org.jheuristics.util.RandomGenerator;

/**
 * TODO
 *
 * @author Marcell Manfrin, marcell@ourgrid.org, Jan 9, 2006
 */
public class StochasticUniversalSampingSelector extends AbstractRouletteSelector implements Serializable {
	private Double minimalValue;

    /**
     * TODO
     *
     * @param transformation
     */
    public StochasticUniversalSampingSelector(FitnessScaler transformation) {
		this(transformation, null);
    }

    /**
     * TODO
     *
     * @param transformation
     * @param minimalValue
     */
    public StochasticUniversalSampingSelector(FitnessScaler transformation, Double minimalValue) {
		super(transformation);
		setMinimalValue(minimalValue);
    }

	/**
	 * TODO
	 *
	 * @param fitness
	 * @param random
	 * @return
	 * @see org.jheuristics.ga.operators.selectors.AbstractRouletteSelector#createRoulette(double[], org.jheuristics.util.RandomGenerator)
	 */
	protected Roulette createRoulette(double[] fitness, RandomGenerator random) {
		if (null == minimalValue) {
			return new SUSRoulette(fitness, random);
		} else {
			return new SUSRoulette(fitness, minimalValue.doubleValue(), random);
		}
	}

	/**
	 * TODO
	 *
	 * @return
	 */
	public Double getMinimalValue() {
		return minimalValue;
	}

	/**
	 * TODO
	 *
	 * @param minimalValue
	 */
	public void setMinimalValue(Double minimalValue) {
		this.minimalValue = minimalValue;
	}

}
